package com.xuyuan;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Singleton {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        List<String> list1 = Collections.unmodifiableList(list);
        for (String s : list) {
            if ("1".equals(s))
                list.remove(s);
        }
        System.out.println(list1);
    }

    private static Singleton singleton;

    private Singleton() {
    }

    public static Singleton getInstance() {
        if (singleton == null) {
            synchronized (Singleton.class) {
                if (singleton == null) {
                    singleton = new Singleton();
                }
            }
        }
        return singleton;
    }
}
